import fms.acarsMsgProcessUtil.DownLinkDatagramHeader;
import fms.acarsMsgProcessUtil.RawDatagram;
import junit.framework.TestCase;

/**
 * Created with IntelliJ IDEA.
 * Date: 2014/7/7
 * Time: 9:56
 * To change this template use File | Settings | File Templates.
 */
public class acarsMsgProcessCase extends TestCase {


    @Override
    protected void setUp() throws Exception {

    }

    public static void testMsgParse() throws Exception {
//        String rawMsg = "2009-09-25 03:23:47\r\n" +
        String rawMsg =       "\u0001QU ABZDS8X CTUUO3U XYTSO7X\r\n" +
                ".BJSXCXA 260310\r\n" +
                "\u0002FML\r\n" +
                "FI HO1283/AN B-6311\r\n" +
                "DT BJS PVG 260310 F09A\r\n" +
                "-  REQ PWI /CQ351 /WQ351 :ALDAP.IBEGI.ODULO.GORPI.SAGUT.IDVEL.XDX.TAO.XIVID.FD.TEKAM.IGDEG.NIXEP.TANIB.MAKNO.UDETI.VENOS.CHI.NODAL.ISKEM.BIDIB.NUBKI.LEMOT.LJB.ZYCC /DQ351 /WRZYCC.ZYTX A130\r\n"+
                "\u0003";
        System.out.println(RawDatagram.GetHeader(rawMsg));
        DownLinkDatagramHeader msgHeader = DownLinkDatagramHeader.Parse(RawDatagram.GetHeader(rawMsg));

        System.out.println("=====:" + msgHeader.getAdccTime());
        System.out.println("=====:" + msgHeader.getToUserCodes()[0]);
        System.out.println("=====:" + msgHeader.getToUserCodes()[1]);
        System.out.println("=====:" + msgHeader.getToUserCodes()[2]);
        System.out.println("=====:" + msgHeader.getAn());
        System.out.println("=====:" + msgHeader.getBepTime());
        System.out.println("=====:" + msgHeader.getDes());
        System.out.println("=====:" + msgHeader.getDspCode3());
        System.out.println("=====:" + msgHeader.getFromCode());
        System.out.println("=====:" + msgHeader.getPriority());

        // 目前下面的解析方法仅适用于请求一个高度层多个航路点的情况（若多个高度层，请先给出样例）
//        String rawMsg = "REQ PWI /CQ351 /WQ351 :ALDAP.IBEGI.ODULO.GORPI.SAGUT.IDVEL.XDX.TAO.XIVID.FD.TEKAM.IGDEG.NIXEP.TANIB.MAKNO.UDETI.VENOS.CHI.NODAL.ISKEM.BIDIB.NUBKI.LEMOT.LJB.ZYCC /DQ351 /WRZYCC.ZYTX A130";
//        String regexRequestWind = "REQ PWI /CQ\\d+ /WQ(\\d+) :([\\s\\S]*?) /DQ\\d+ /\\w+\\.\\w+ \\w+";
//        Pattern pattern = Pattern.compile(regexRequestWind);
//        Matcher matcher = pattern.matcher(rawMsg);
//        if (matcher.matches()) {
//            String reqAlt = matcher.group(1);
//            String reqCpt = matcher.group(2);
//            System.out.println(reqAlt + "   " + reqCpt);
//        }


//        rawMsg = StringUtil.sideTrim(rawMsg, 10, "\n");
//        System.out.println(rawMsg + "===");
//        Object[] arr =  RemoveEmptyLine(rawMsg);
//        String[] strarr = ObjectToStringArray(arr);
//        for(String item : rawMsg) {
//        System.out.println("==" + strarr[0] + "   "+ strarr.length);
        }
}


